package com.example.tests;

import java.util.Collections;
import java.util.List;

import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;


public class ContactCreationTests extends TestBase {
		
	@Test (dataProvider = "randomValidContactGenerator")
	public void contactCreationTest(ContactData contact) {
		app.getNavigationHelper().openMainPage();
		
		//save old state
		List<ContactData> oldList = app.getContactHelper().getContacts();
		
		//actions
		app.getContactHelper().goToContactCreationPage();
		app.getContactHelper().fillContactForm(contact, true);
	    app.getGroupHelper().submitNewValueCreation(app);
		app.getContactHelper().returnToHomePage();
		
		//save new state
		List<ContactData> newList = app.getContactHelper().getContacts();
		
		//compare states
		assertEquals(newList.size(), oldList.size()+1);
		oldList.add(contact);
		Collections.sort(oldList);
		assertEquals(newList, oldList);
	}
	
	}
